#include <iostream>
#include <memory>
#include <vector>
#include <limits>
#include <algorithm>
#include <unistd.h>
#include <chrono>
#include <list>
#include <forward_list>

using namespace std;

// using array instead of int[] like array is recommended for safety

template<typename T>
void print_iterable(const char* s, T& t){
    cout<<s<<": ";
    for (auto& i : t)
        cout<<i<<" ";
    cout<<endl;
}



int test_list_forward_list(){
    vector<int> vec{1,2,3,4,5};
    list<int> list(vec.begin(), vec.end());
    print_iterable("init", list);


    cout<<list.size()<<endl;
    cout<<list.empty()<<endl;
    list.emplace_back(1000);
    print_iterable("After emplace", list);

    list.resize(10,10);
    print_iterable("After resize", list);

    list.assign({6,5,4,3,2,1});
    print_iterable("After assign", list);
    list.assign(vec.begin(), vec.begin()+3);
    print_iterable("After range assign", list);

    list.emplace_back(9);
    list.pop_back();
    list.pop_front();
    list.insert(++list.begin(), -1);
    print_iterable("After all shit:", list);

    cout<<"------------------ - --- ------------------"<<endl;

    auto fl = forward_list<int>();
    fl.assign({12,2,4,5,6});
    print_iterable("assign", fl);

    //fl.push_front(-888);
    fl.insert_after(fl.before_begin(), -888);
    fl.insert_after(fl.begin(), 999);
    print_iterable("After insert", fl);
}
